package com.example.collectionlinkmanagementsystem.controller;

import com.example.collectionlinkmanagementsystem.entity.LinkBean;
import com.example.collectionlinkmanagementsystem.mapper.LinkMapper;
import com.example.collectionlinkmanagementsystem.service.LinkService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2023/5/13 1:12
 */
@CrossOrigin
@RestController
@RequestMapping("/link")
public class LinkController {
    @Resource
    LinkService linkService;
    @RequestMapping("/getAny")
    public List<LinkBean> getAny(@RequestBody LinkBean linkBean) {
        System.out.println(linkBean);
        return linkService.getAll(linkBean);
    }

    @RequestMapping("/getAll")
    public List<LinkBean> getAll() {
        return linkService.getAll(new LinkBean());
    }

    @RequestMapping("/count")
    public Integer count(@RequestBody(required = false) LinkBean linkBean) {
        return linkService.count(linkBean);
    }

    @PostMapping("/removeLink")
    public Integer removeLink(@RequestBody LinkBean linkBean) {
        System.out.println(linkBean);
        return linkService.removeLink(linkBean);
    }



    @PostMapping("/updateLink")
    public Integer updateLink(@RequestBody LinkBean linkBean) {
        System.out.println(linkBean);

        return linkService.updateLink(linkBean);
    }

    @PostMapping("/addLink")
    public Integer addLink(@RequestBody LinkBean linkBean) {
        return linkService.addLink(linkBean);
    }
}
